package com.tbit.main.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.tbit.main.dao.log.UpKeepTypeLogDao;
import com.tbit.main.pojo.UpKeepTypeLog;
import com.tbit.main.service.UpKeepTypeLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author yao
 * @since 2025/2/18 14:21
 */
@Service
public class UpKeepTypeLogServiceImpl implements UpKeepTypeLogService {

    @Resource
    private UpKeepTypeLogDao upKeepTypeLogDao;

    @Override
    public void saveBatch(List<UpKeepTypeLog> upKeepTypeLogs) {
        upKeepTypeLogDao.insertBatch(upKeepTypeLogs);
    }

    @Override
    public List<UpKeepTypeLog> getByUpKeepLogId(Integer upKeepLogId) {
        return upKeepTypeLogDao.selectByUpKeepLogId(upKeepLogId);
    }

    @Override
    public Map<Integer, List<UpKeepTypeLog>> getByUpKeepLogIds(List<Integer> upKeepLogId) {
        return CollUtil.isEmpty(upKeepLogId)
                ? Collections.emptyMap()
                : upKeepTypeLogDao.selectByUpKeepLogIds(upKeepLogId)
                .stream().collect(Collectors.groupingBy(UpKeepTypeLog::getUpKeepLogId));
    }

}
